/*
	Name:【模板】LCA
	Author: There,hello 
	Date: 16-07-19 21:30
	Description: Luogu P3379
	Algorithm: 欧拉序+Rmq
*/
#include<bits/stdc++.h>
using namespace std;
int head[500011],tail,tail_dfs=1,dfsxu[1000012],deep[1000011],n,q,s,lg[1000012]={-1},mi[22]={1},st[22][1000011],first[500012];
struct dd{
	int next,to;
}side[1000012];
inline void add(int x,int y){
	side[++tail].to=y;
	side[tail].next=head[x];
	head[x]=tail;
}
void dfs(int t,int fa,int deepth){
	for(int i=head[t];i;i=side[i].next){
		if(side[i].to!=fa){
			dfsxu[++tail_dfs]=side[i].to;
			deep[tail_dfs]=deepth+1;
			st[0][tail_dfs]=tail_dfs;
			first[side[i].to]=tail_dfs;
			dfs(side[i].to,t,deepth+1);
			dfsxu[++tail_dfs]=t;
			deep[tail_dfs]=deepth;
			st[0][tail_dfs]=tail_dfs;
		}
	}
}
void st_ready(){
	for(int i=1;i<=(n<<1);++i) 
	lg[i]=lg[i>>1]+1;
	for(int i=1;i<=21;++i)
	mi[i]=(mi[i-1]<<1);
	for(int i=1;i<=lg[(n<<1)-1];++i)
		for(int j=1;j+mi[i]-1<=((n<<1)-1);++j)
			st[i][j]=deep[st[i-1][j]]<deep[st[i-1][j+mi[i-1]]]?st[i-1][j]:st[i-1][j+mi[i-1]];
}
int main(){
	scanf("%d%d%d",&n,&q,&s);
	for(int i=1,x,y;i<n;++i){
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	dfsxu[1]=s;
	deep[1]=1;
	st[0][1]=1;
	first[s]=1;
	dfs(s,0,1);
	st_ready();
	while(q--){
		int x,y;
		scanf("%d%d",&x,&y);
		int l=first[y],r=first[x];
		if(r<l)swap(l,r);
		int log=lg[r-l+1]; 
		printf("%d",deep[st[log][l]]<deep[st[log][r-mi[log]+1]]?dfsxu[st[log][l]]:dfsxu[st[log][r-mi[log]+1]]);
		putchar('\n');
	}
	return 0;
} 